Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@salesforce/ts-types

Package Overview
Dependencies
Maintainers
47
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/ts-types

Types and related utilities for TypeScript

  • 2.0.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
630K
decreased by-48.85%
Maintainers
47
Weekly downloads
 
Created

What is @salesforce/ts-types?

@salesforce/ts-types is a TypeScript utility library that provides a set of type definitions and utilities to help with type-safe programming in TypeScript. It is particularly useful for Salesforce developers who need to work with complex types and ensure type safety in their applications.

What are @salesforce/ts-types's main functionalities?

Optional

The `Optional` type allows you to define a type that can either be a specific type or `undefined`. This is useful for handling optional parameters or properties in a type-safe manner.

import { Optional } from '@salesforce/ts-types';

function getLength(str: Optional<string>): number {
  return str ? str.length : 0;
}

console.log(getLength('Hello')); // 5
console.log(getLength(undefined)); // 0

Dictionary

The `Dictionary` type is a utility type that represents an object with string keys and values of a specified type. This is useful for creating objects that act as maps or dictionaries.

import { Dictionary } from '@salesforce/ts-types';

const userRoles: Dictionary<string> = {
  'admin': 'Administrator',
  'user': 'Regular User'
};

console.log(userRoles['admin']); // 'Administrator'

Nullable

The `Nullable` type allows you to define a type that can either be a specific type or `null`. This is useful for handling nullable values in a type-safe manner.

import { Nullable } from '@salesforce/ts-types';

function greet(name: Nullable<string>): string {
  return name ? `Hello, ${name}!` : 'Hello!';
}

console.log(greet('Alice')); // 'Hello, Alice!'
console.log(greet(null)); // 'Hello!'

Other packages similar to @salesforce/ts-types

FAQs

Package last updated on 29 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc